<?php
class ml_model_guang_rdsTag extends ml_model_redis
{
    const TAG_KEY_PREFFIX = 'tag_hash_';
    const TAG_PT_KEY_PREFFIX = 'tag_pt_';
    const TAGID_KEY_PREFFIX = 'tag2id_';
    const TAG_HOT_KEY_PREFFIX = 'tag_hot_';
    function __construct() {
        if(!$this->init_rds('meila_cache'))
        return false;
    }

    /**
     *获取标签数组
     */

    public function getCtgTag($tags) {
        $tagGroup = $this->get(self::TAG_KEY_PREFFIX.$tags);
        return $tagGroup;
    }
    public function flushByPrefix($prefix)
    {
        $aTag = $this->keys(self::TAG_KEY_PREFFIX.'*');
        foreach ($aTag as $key => $value) {
            $this->delete($value);
        }
        return $aTag;
    }
    public function setCtgTag($tag_hash , $value)
    {
        echo self::TAG_KEY_PREFFIX.$tag_hash;
        $this->set(self::TAG_KEY_PREFFIX.$tag_hash , $value);
    }
    public function setTagPt($tag_hash , $value)
    {
        $this->set(self::TAG_PT_KEY_PREFFIX.$tag_hash , $value);
    }
    public function getTagPt($tag_hash) {
        return $this->get(self::TAG_PT_KEY_PREFFIX.$tag_hash);
    }
    /**
     *获取标签数组
     */
    public function getTagId($tag_hash) {
        $tagid = $this->get(self::TAGID_KEY_PREFFIX.$tag_hash);
        return $tagid;
    }
    /**
     * 判断此标签是否存在热门标签中
     **/
    public function taghot_exists($tag,$cate='guang'){
        return $this->zScore(self::TAG_HOT_KEY_PREFFIX.$cate, $tag);
    }
    /**
     * 判断此标签是否存在热门标签中
     **/
    public function get_taghot($start, $end,$cate='guang'){
        if(empty($cate))
            $cate = 'guang';
        $start = 0;
        return $this->zRange(self::TAG_HOT_KEY_PREFFIX.$cate, $start, $end);
    }


}